package com.fast.modules.acd.service.impl.jvm;

import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.stream.Stream;

import com.fast.modules.acd.entity.Seat;
import com.fast.modules.acd.service.SeatStorageService;

/**
 * 坐席的map默认存储
 * @author yaoyuquan
 *
 */
public class SeatStorageServiceJVMImpl implements SeatStorageService {
	
	/**
	 * 坐席的信息
	 * key是坐席ID
	 * value是坐席的实体对象
	 * 坐席上线后向map中插入一条数据
	 * 坐席下线后需要从map中清除
	 */
	private static Map<String, Seat> map = new HashMap<>();

	@Override
	public Map<String, Seat> map() {
		return map;
	}

	@Override
	public Seat put(String seatID, Seat seat) {
		return map.put(seatID, seat);
	}

	@Override
	public Seat remove(String seatID) {
		return map.remove(seatID);
	}

	@Override
	public Stream<Seat> stream() {
		return map.entrySet().stream().map(Entry::getValue);
	}

	@Override
	public boolean containsKey(String seatID) {
		return map.containsKey(seatID);
	}

	@Override
	public Seat get(String seatID) {
		return map.get(seatID);
	}

}
